<template>
  <BasicForm @register="registerForm"> </BasicForm>
</template>

<script lang="ts" setup>
  import { BasicForm, useForm, FormSchema } from '/@/components/Form';
  import { modalFormStyleSetting } from '/@/settings/thingsBoardDesign';

  import { onMounted, watch } from 'vue';

  const props = defineProps(['saveFlag', 'formOptions']);
  const emits = defineEmits(['getFormData']);

  let schemas: FormSchema[] = [];

  watch(
    () => props.saveFlag,
    async (_nVal) => {
      // 导出数据
      try {
        let formData = await validate();
        emits('getFormData', { formOption: formData });
      } catch (error) {
        emits('getFormData', 'error');
      }
    },
  );

  watch(
    () => props.formOptions,
    (nVal) => {
      
    },
    {
      immediate: true,
    },
  );

  const [registerForm, { validate, updateSchema }] = useForm({
    layout: 'vertical',
    schemas,
    showActionButtonGroup: false,
    ...modalFormStyleSetting,
  });
</script>
